home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / Externalizable.java < prev    next >
Text File  |  1998-09-22  |  3KB  |  72 lines

  1. /*
  2.  * @(#)Externalizable.java    1.7 98/07/01
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.io;
  16.  
  17. import java.io.ObjectOutput;
  18. import java.io.ObjectInput;
  19.  
  20. /**
  21.  * Externalization allows a class to specify the methods to be used to
  22.  * write the object's contents to a stream and to read them back.  The
  23.  * Externalizable interface's writeExternal and readExternal methods
  24.  * are implemented by a class to
  25.  * give the class complete control over the format and contents of the
  26.  * stream for an object and its supertypes. These methods must explicitly
  27.  * coordinate with the supertype to save its state. <br>
  28.  *
  29.  * Object Serialization uses the Serializable and Externalizable
  30.  * interfaces.  Object persistence mechanisms may use them also.  Each
  31.  * object to be stored is tested for the Externalizable interface. If
  32.  * the object supports it, the writeExternal method is called. If the
  33.  * object does not support Externalizable and does implement
  34.  * Serializable the object should be saved using
  35.  * ObjectOutputStream. <br> When an Externalizable object is to be
  36.  * reconstructed, an instance is created using the public no-arg
  37.  * constructor and the readExternal method called.  Serializable
  38.  * objects are restored by reading them from an ObjectInputStream.
  39.  *
  40.  * @author  unascribed
  41.  * @version 1.7, 07/01/98
  42.  * @see java.io.ObjectOutputStream
  43.  * @see java.io.ObjectInputStream
  44.  * @see java.io.ObjectOutput
  45.  * @see java.io.ObjectInput
  46.  * @see java.io.Serializable
  47.  * @since   JDK1.1
  48.  */
  49. public interface Externalizable extends java.io.Serializable {
  50.     /**
  51.      * The object implements the writeExternal method to save its contents
  52.      * by calling the methods of DataOutput for its primitive values or
  53.      * calling the writeObject method of ObjectOutput for objects, strings
  54.      * and arrays.
  55.      * @exception IOException Includes any I/O exceptions that may occur
  56.      * @since     JDK1.1
  57.      */
  58.     void writeExternal(ObjectOutput out) throws IOException;
  59.  
  60.     /**
  61.      * The object implements the readExternal method to restore its
  62.      * contents by calling the methods of DataInput for primitive
  63.      * types and readObject for objects, strings and arrays.  The
  64.      * readExternal method must read the values in the same sequence
  65.      * and with the same types as were written by writeExternal.
  66.      * @exception ClassNotFoundException If the class for an object being
  67.      *              restored cannot be found.
  68.      * @since     JDK1.1
  69.      */
  70.     void readExternal(ObjectInput in) throws IOException, ClassNotFoundException;
  71. }
  72.